home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / Delphi 3.0 / DATA.Z / DTIMPL.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-01-30  |  9.6 KB  |  348 lines

  1. unit DTImpl;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  7.   ComServ, StdVCL, AXCtrls, DelLib, ComCtrls;
  8.  
  9. type
  10.   TDateTimePickerX = class(TActiveXControl, IDateTimePickerX)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TDateTimePicker;
  14.     FEvents: IDateTimePickerXEvents;
  15.     procedure ChangeEvent(Sender: TObject);
  16.     procedure ClickEvent(Sender: TObject);
  17.     procedure CloseUpEvent(Sender: TObject);
  18.     procedure DblClickEvent(Sender: TObject);
  19.     procedure DropDownEvent(Sender: TObject);
  20.     procedure KeyPressEvent(Sender: TObject; var Key: Char);
  21.     procedure UserInputEvent(Sender: TObject; const UserString: String;
  22.       var DateAndTime: TDateTime; var AllowChange: Boolean);
  23.   protected
  24.     { Protected declarations }
  25.     procedure InitializeControl; override;
  26.     procedure EventSinkChanged(const EventSink: IUnknown); override;
  27.     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
  28.     function Get_CalAlignment: TxDTCalAlignment; safecall;
  29.     function Get_Checked: WordBool; safecall;
  30.     function Get_Color: TColor; safecall;
  31.     function Get_Cursor: Smallint; safecall;
  32.     function Get_Date: Double; safecall;
  33.     function Get_DateFormat: TxDTDateFormat; safecall;
  34.     function Get_DateMode: TxDTDateMode; safecall;
  35.     function Get_DragCursor: Smallint; safecall;
  36.     function Get_Enabled: WordBool; safecall;
  37.     function Get_Font: Font; safecall;
  38.     function Get_ImeName: WideString; safecall;
  39.     function Get_Kind: TxDateTimeKind; safecall;
  40.     function Get_MaxDate: Double; safecall;
  41.     function Get_MinDate: Double; safecall;
  42.     function Get_ParentColor: WordBool; safecall;
  43.     function Get_ParseInput: WordBool; safecall;
  44.     function Get_ShowCheckbox: WordBool; safecall;
  45.     function Get_Time: Double; safecall;
  46.     function Get_Visible: WordBool; safecall;
  47.     procedure AboutBox; safecall;
  48.     procedure Set_CalAlignment(Value: TxDTCalAlignment); safecall;
  49.     procedure Set_Checked(Value: WordBool); safecall;
  50.     procedure Set_Color(Value: TColor); safecall;
  51.     procedure Set_Cursor(Value: Smallint); safecall;
  52.     procedure Set_Date(Value: Double); safecall;
  53.     procedure Set_DateFormat(Value: TxDTDateFormat); safecall;
  54.     procedure Set_DateMode(Value: TxDTDateMode); safecall;
  55.     procedure Set_DragCursor(Value: Smallint); safecall;
  56.     procedure Set_Enabled(Value: WordBool); safecall;
  57.     procedure Set_Font(const Value: Font); safecall;
  58.     procedure Set_ImeName(const Value: WideString); safecall;
  59.     procedure Set_Kind(Value: TxDateTimeKind); safecall;
  60.     procedure Set_MaxDate(Value: Double); safecall;
  61.     procedure Set_MinDate(Value: Double); safecall;
  62.     procedure Set_ParentColor(Value: WordBool); safecall;
  63.     procedure Set_ParseInput(Value: WordBool); safecall;
  64.     procedure Set_ShowCheckbox(Value: WordBool); safecall;
  65.     procedure Set_Time(Value: Double); safecall;
  66.     procedure Set_Visible(Value: WordBool); safecall;
  67.   end;
  68.  
  69. implementation
  70. uses DTPg;
  71. { TDateTimePickerX }
  72.  
  73. procedure TDateTimePickerX.InitializeControl;
  74. begin
  75.   FDelphiControl := Control as TDateTimePicker;
  76.   FDelphiControl.OnChange := ChangeEvent;
  77.   FDelphiControl.OnClick := ClickEvent;
  78.   FDelphiControl.OnCloseUp := CloseUpEvent;
  79.   FDelphiControl.OnDblClick := DblClickEvent;
  80.   FDelphiControl.OnDropDown := DropDownEvent;
  81.   FDelphiControl.OnKeyPress := KeyPressEvent;
  82.   FDelphiControl.OnUserInput := UserInputEvent;
  83. end;
  84.  
  85. procedure TDateTimePickerX.EventSinkChanged(const EventSink: IUnknown);
  86. begin
  87.   FEvents := EventSink as IDateTimePickerXEvents;
  88. end;
  89.  
  90. procedure TDateTimePickerX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  91. begin
  92.   { Define property pages here.  Property pages are defined by calling
  93.     DefinePropertyPage with the class id of the page.  For example,
  94.       DefinePropertyPage(Class_DateTimePickerXPage); }
  95. end;
  96.  
  97. function TDateTimePickerX.Get_CalAlignment: TxDTCalAlignment;
  98. begin
  99.   Result := Ord(FDelphiControl.CalAlignment);
  100. end;
  101.  
  102. function TDateTimePickerX.Get_Checked: WordBool;
  103. begin
  104.   Result := FDelphiControl.Checked;
  105. end;
  106.  
  107. function TDateTimePickerX.Get_Color: TColor;
  108. begin
  109.   Result := FDelphiControl.Color;
  110. end;
  111.  
  112. function TDateTimePickerX.Get_Cursor: Smallint;
  113. begin
  114.   Result := Smallint(FDelphiControl.Cursor);
  115. end;
  116.  
  117. function TDateTimePickerX.Get_Date: Double;
  118. begin
  119.   Result := Double(FDelphiControl.Date);
  120. end;
  121.  
  122. function TDateTimePickerX.Get_DateFormat: TxDTDateFormat;
  123. begin
  124.   Result := Ord(FDelphiControl.DateFormat);
  125. end;
  126.  
  127. function TDateTimePickerX.Get_DateMode: TxDTDateMode;
  128. begin
  129.   Result := Ord(FDelphiControl.DateMode);
  130. end;
  131.  
  132. function TDateTimePickerX.Get_DragCursor: Smallint;
  133. begin
  134.   Result := Smallint(FDelphiControl.DragCursor);
  135. end;
  136.  
  137. function TDateTimePickerX.Get_Enabled: WordBool;
  138. begin
  139.   Result := FDelphiControl.Enabled;
  140. end;
  141.  
  142. function TDateTimePickerX.Get_Font: Font;
  143. begin
  144.   GetOleFont(FDelphiControl.Font, Result);
  145. end;
  146.  
  147. function TDateTimePickerX.Get_ImeName: WideString;
  148. begin
  149.   Result := WideString(FDelphiControl.ImeName);
  150. end;
  151.  
  152. function TDateTimePickerX.Get_Kind: TxDateTimeKind;
  153. begin
  154.   Result := Ord(FDelphiControl.Kind);
  155. end;
  156.  
  157. function TDateTimePickerX.Get_MaxDate: Double;
  158. begin
  159.   Result := Double(FDelphiControl.MaxDate);
  160. end;
  161.  
  162. function TDateTimePickerX.Get_MinDate: Double;
  163. begin
  164.   Result := Double(FDelphiControl.MinDate);
  165. end;
  166.  
  167. function TDateTimePickerX.Get_ParentColor: WordBool;
  168. begin
  169.   Result := FDelphiControl.ParentColor;
  170. end;
  171.  
  172. function TDateTimePickerX.Get_ParseInput: WordBool;
  173. begin
  174.   Result := FDelphiControl.ParseInput;
  175. end;
  176.  
  177. function TDateTimePickerX.Get_ShowCheckbox: WordBool;
  178. begin
  179.   Result := FDelphiControl.ShowCheckbox;
  180. end;
  181.  
  182. function TDateTimePickerX.Get_Time: Double;
  183. begin
  184.   Result := Double(FDelphiControl.Time);
  185. end;
  186.  
  187. function TDateTimePickerX.Get_Visible: WordBool;
  188. begin
  189.   Result := FDelphiControl.Visible;
  190. end;
  191.  
  192. procedure TDateTimePickerX.AboutBox;
  193. begin
  194.   ShowDateTimePickerXAbout;
  195. end;
  196.  
  197. procedure TDateTimePickerX.Set_CalAlignment(Value: TxDTCalAlignment);
  198. begin
  199.   FDelphiControl.CalAlignment := TDTCalAlignment(Value);
  200. end;
  201.  
  202. procedure TDateTimePickerX.Set_Checked(Value: WordBool);
  203. begin
  204.   FDelphiControl.Checked := Value;
  205. end;
  206.  
  207. procedure TDateTimePickerX.Set_Color(Value: TColor);
  208. begin
  209.   FDelphiControl.Color := Value;
  210. end;
  211.  
  212. procedure TDateTimePickerX.Set_Cursor(Value: Smallint);
  213. begin
  214.   FDelphiControl.Cursor := TCursor(Value);
  215. end;
  216.  
  217. procedure TDateTimePickerX.Set_Date(Value: Double);
  218. begin
  219.   FDelphiControl.Date := TDate(Value);
  220. end;
  221.  
  222. procedure TDateTimePickerX.Set_DateFormat(Value: TxDTDateFormat);
  223. begin
  224.   FDelphiControl.DateFormat := TDTDateFormat(Value);
  225. end;
  226.  
  227. procedure TDateTimePickerX.Set_DateMode(Value: TxDTDateMode);
  228. begin
  229.   FDelphiControl.DateMode := TDTDateMode(Value);
  230. end;
  231.  
  232. procedure TDateTimePickerX.Set_DragCursor(Value: Smallint);
  233. begin
  234.   FDelphiControl.DragCursor := TCursor(Value);
  235. end;
  236.  
  237. procedure TDateTimePickerX.Set_Enabled(Value: WordBool);
  238. begin
  239.   FDelphiControl.Enabled := Value;
  240. end;
  241.  
  242. procedure TDateTimePickerX.Set_Font(const Value: Font);
  243. begin
  244.   SetOleFont(FDelphiControl.Font, Value);
  245. end;
  246.  
  247. procedure TDateTimePickerX.Set_ImeName(const Value: WideString);
  248. begin
  249.   FDelphiControl.ImeName := TImeName(Value);
  250. end;
  251.  
  252. procedure TDateTimePickerX.Set_Kind(Value: TxDateTimeKind);
  253. begin
  254.   FDelphiControl.Kind := TDateTimeKind(Value);
  255. end;
  256.  
  257. procedure TDateTimePickerX.Set_MaxDate(Value: Double);
  258. begin
  259.   FDelphiControl.MaxDate := TDate(Value);
  260. end;
  261.  
  262. procedure TDateTimePickerX.Set_MinDate(Value: Double);
  263. begin
  264.   FDelphiControl.MinDate := TDate(Value);
  265. end;
  266.  
  267. procedure TDateTimePickerX.Set_ParentColor(Value: WordBool);
  268. begin
  269.   FDelphiControl.ParentColor := Value;
  270. end;
  271.  
  272. procedure TDateTimePickerX.Set_ParseInput(Value: WordBool);
  273. begin
  274.   FDelphiControl.ParseInput := Value;
  275. end;
  276.  
  277. procedure TDateTimePickerX.Set_ShowCheckbox(Value: WordBool);
  278. begin
  279.   FDelphiControl.ShowCheckbox := Value;
  280. end;
  281.  
  282. procedure TDateTimePickerX.Set_Time(Value: Double);
  283. begin
  284.   FDelphiControl.Time := TTime(Value);
  285. end;
  286.  
  287. procedure TDateTimePickerX.Set_Visible(Value: WordBool);
  288. begin
  289.   FDelphiControl.Visible := Value;
  290. end;
  291.  
  292. procedure TDateTimePickerX.ChangeEvent(Sender: TObject);
  293. begin
  294.   if FEvents <> nil then FEvents.OnChange;
  295. end;
  296.  
  297. procedure TDateTimePickerX.ClickEvent(Sender: TObject);
  298. begin
  299.   if FEvents <> nil then FEvents.OnClick;
  300. end;
  301.  
  302. procedure TDateTimePickerX.CloseUpEvent(Sender: TObject);
  303. begin
  304.   if FEvents <> nil then FEvents.OnCloseUp;
  305. end;
  306.  
  307. procedure TDateTimePickerX.DblClickEvent(Sender: TObject);
  308. begin
  309.   if FEvents <> nil then FEvents.OnDblClick;
  310. end;
  311.  
  312. procedure TDateTimePickerX.DropDownEvent(Sender: TObject);
  313. begin
  314.   if FEvents <> nil then FEvents.OnDropDown;
  315. end;
  316.  
  317. procedure TDateTimePickerX.KeyPressEvent(Sender: TObject; var Key: Char);
  318. var
  319.   TempKey: Smallint;
  320. begin
  321.   TempKey := Smallint(Key);
  322.   if FEvents <> nil then FEvents.OnKeyPress(TempKey);
  323.   Key := Char(TempKey);
  324. end;
  325.  
  326. procedure TDateTimePickerX.UserInputEvent(Sender: TObject;
  327.   const UserString: String; var DateAndTime: TDateTime;
  328.   var AllowChange: Boolean);
  329. var
  330.   TempDateAndTime: TDateTime;
  331.   TempAllowChange: WordBool;
  332. begin
  333.   TempDateAndTime := TDateTime(DateAndTime);
  334.   TempAllowChange := WordBool(AllowChange);
  335.   if FEvents <> nil then FEvents.OnUserInput(WideString(UserString), TempDateAndTime, TempAllowChange);
  336.   AllowChange := Boolean(TempAllowChange);
  337. end;
  338.  
  339. initialization
  340.   TActiveXControlFactory.Create(
  341.     ComServer,
  342.     TDateTimePickerX,
  343.     TDateTimePicker,
  344.     Class_DateTimePickerX,
  345.     6,
  346.     '{5A565977-7975-11D0-BE02-00A024D1875C}');
  347. end.
  348.